package org.zero.onlinesubject.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class IDWorker {
    private static final String USER_ID_PREFIX = "UID";
    private static final String COURSE_ID_PREFIX = "CID";
    private static final String CLASS_ID_PREFIX = "CLS";
    private static final String LIVE_ID_PREFIX = "LIVE";
    private static final String GROUP_ID_PREFIX = "GID";
    private static final String FILE_ID_PREFIX = "FID";
    private static final String TASK_ID_PREFIX = "TASK";;
    private static final String RECORD_ID_PREFIX = "RC";
    private static final String CHAPTER_ID_PREFIX = "CPID";
    private static final String VIDEO_ID_PREFIX = "VID";

    public static String createUID(){
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        String subfix = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")).toString();
        return USER_ID_PREFIX + subfix;
    }

    public static String createVideoID(){
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        String subfix = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")).toString();
        return VIDEO_ID_PREFIX + subfix;
    }

    public static String createCID(){
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return COURSE_ID_PREFIX + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")).toString();
    }

    public static String createCPID(){
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return CHAPTER_ID_PREFIX + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSS")).toString();
    }

    public static String createCLSID(){
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return CLASS_ID_PREFIX + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSS")).toString();
    }

    public static String createLiveID(){
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return LIVE_ID_PREFIX + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSS")).toString();
    }

    public static String createGID(){
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return GROUP_ID_PREFIX + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")).toString();
    }

    public static String createFID(){
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return FILE_ID_PREFIX + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")).toString();
    }

    public static String createTaskID(){
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return TASK_ID_PREFIX + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSS")).toString();
    }

    public static String createRecordID(){
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return RECORD_ID_PREFIX + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")).toString();
    }
}
